# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-ca-certs-nss
_pkgname=ca-certs-nss
pkgver=3.77
pkgrel=0
pkgdesc="X.509 trust anchors extracted from Mozilla's NSS"
url="https://github.com/mirage/ca-certs-nss"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-mirage-clock
	ocaml-mirage-crypto
	ocaml-x509
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-mirage-clock-dev
	ocaml-mirage-crypto-dev
	ocaml-x509-dev
	"
makedepends="
	$depends_dev
	dune
	ocaml
	ocaml-astring-dev
	ocaml-bos-dev
	ocaml-cmdliner-dev
	ocaml-logs-dev
	ocaml-fmt-dev
	gmp-dev
	"
checkdepends="ocaml-alcotest-dev"
options="!check"
subpackages="$pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/ca-certs-nss/releases/download/v$pkgver/ca-certs-nss-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

tools() {
	pkgdesc="$pkgdesc (command line utilities)"
	depends=""

	amove usr/bin
}

sha512sums="
fdeadfd8decdb1441b9d41ab2a8a747c66cf4029031ab6528a7930d372b945d0a5d3ba1702ec076f6eb71659d788c7c0db5f685339e5ba09de4f52cf882c5764  ocaml-ca-certs-nss-3.77.tar.bz2
"
